package com.zyl.Ecs.common.domain.auth.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.zyl.Ecs.common.domain.auth.ext.PermissionExt;
import com.zyl.Ecs.common.utils.ObjectUtil;
import lombok.Builder;
import lombok.Data;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.auth.domain.vo
 * @ClassName: PermissionVO
 * @Description TODO (权限VO)
 * @Author 翟玉龙
 * @Date 2024/12/4-16:57
 */
@Data
@Builder
public class PermissionVO {

    @JsonProperty(value = "id")
    private Integer id;

    @JsonProperty(value = "name")
    private String name;

    @JsonProperty(value = "path")
    private String path;

    @JsonProperty(value = "key")
    private String key;

    @JsonProperty(value = "icon")
    private String icon;

    public static PermissionVO toVO(PermissionExt permissionExt) {
        if (ObjectUtil.isNull(permissionExt)) {
            return null;
        }
        return PermissionVO.builder()
                .id(permissionExt.getId())
                .name(permissionExt.getName())
                .path(permissionExt.getPath())
                .key(permissionExt.getKey())
                .icon(permissionExt.getIcon())
                .build();
    }
}
